<?php
use common\service\StaticService;
use backend\assets\AdminAsset;
use common\service\GlobalUrlService;

StaticService::includeAppCssStatic(GlobalUrlService::buildStaticUrl('/css/supplier/update.css'),AdminAsset::class);
StaticService::includeAppJsStatic(GlobalUrlService::buildStaticUrl('/backend/qiniu.min.js'),AdminAsset::class);
StaticService::includeAppJsStatic(GlobalUrlService::buildStaticUrl('/backend/supplier/update.js'),AdminAsset::class);

?>
<div class="content_box">
  <div class="edit_goods">
    <form class="layui-form">
      <ul class="form_ul">
        <li>
          <span class="title">商品分类</span>
          <div class="layui-inline">
            <div class="layui-input-inline">
              <select lay-verify="required" class="span2 oneclass" data-placeholder="Choose a Category" tabindex="1" name="tree_id" lay-filter="one">
                <option value="0">请选择主营类目</option>
                  <?php foreach ($onetree as $val):?>
                    <option value="<?=$val['id']?>" <?php if($val['id'] == $goods['one_tree_id']):?> selected="selected" <?php endif;?>><?=$val['tree_name']?></option>
                  <?php endforeach;?>
              </select>
            </div>

            <div class="layui-input-inline">
              <select lay-verify="required" class="span2 twoclass" data-placeholder="Choose a Category" tabindex="1" name="tree_id" lay-filter="two">
                <?php foreach ($twotree as $val):?>
                  <option value="<?=$val['id']?>" <?php if($val['id'] == $goods['two_tree_id']):?> selected="selected" <?php endif;?>><?=$val['tree_name']?></option>
                <?php endforeach;?>
              </select>
            </div>

            <div class="layui-input-inline">
                  <select class="threeclass" name="three_id">
                      <?php foreach ($threetree as $val):?>
                          <option value="<?=$val['id']?>" <?php if($val['id'] == $goods['three_tree_id']):?> selected="selected" <?php endif;?>><?=$val['tree_name']?></option>
                      <?php endforeach;?>
                  </select>
            </div>
          </div>
        </li>
        <li>
          <span class="title" class="layui-inline">商品名称</span>
          <div class="item">
            <input type="text" class="layui-input layui-input-inline menu-name" name="goods_name" value="<?= $goods['goods_name']?>" />
            <span class="menu_name_count">0</span>/45
          </div>
        </li>
        <li>
          <span class="title" class="layui-inline">商品类别</span>
          <div class="item">
            <input type="radio" title="商城" value="0" name="goods_type" <?php if($goods['goods_type'] == 0):echo 'checked';endif;?>/>
            <input type="radio" title="推荐" value="2" name="goods_type" <?php if($goods['goods_type'] == 2):echo 'checked';endif;?>/>
            <input type="radio" title="热门" value="3" name="goods_type" <?php if($goods['goods_type'] == 3):echo 'checked';endif;?>/>
            <input type="radio" title="新品" value="4" name="goods_type" <?php if($goods['goods_type'] == 4):echo 'checked';endif;?>/>
            <input type="radio" title="折扣" value="5" name="goods_type" <?php if($goods['goods_type'] == 5):echo 'checked';endif;?>/>
          </div>
        </li>
        <li class="edit_cover">
          <span class="title">封面图</span>
          <div class="layui-inline">
            <label class="upload_cover" for="pic-card3">
              <span class="layui-btn" >
                <i class="layui-icon">&#xe67c;</i>修改封面图
              </span>
            </label>
            <input type="file" class="pic-card3" id="pic-card3">
            <input type="hidden" name="list_img" value="<?= $goods['list_img']?>" class="hidden-pic3">
            <img src="<?php if($goods['list_img']):echo GlobalUrlService::buildCdnUrl($goods['list_img']); else: echo '/img/add-pic.png';endif;?>" class="pic3" />
          </div>

        </li>
        <li>
          <span class="title">商品规格</span>
          <div class="item">
            <div class="controls">
              <!-- <div class="size-warpper">
                <span class="layui-btn layui-inline add-attr" style="font-size: 25px;font-weight: bold;">+</span>
              </div>
              <div class="hide add-attr-warpper">
                <div class="control-group layer-attr-tit">
                  <label class="layui-inline">规格名称:</label>
                  <div class="controls layui-inline">
                    <input type="text" id="attr_name" name="attr_name" class="layui-input" placeholder="请输入规格名称">
                  </div>
                </div>
                <div class="text-align-center">
                  <div>
                    <button type="button" class="layui-btn do">提交</button>
                    <button type="button" class="layui-btn layui-btn-primary cancel">取消</button>
                  </div>
                </div>
              </div> -->

              <!-- <div class="layui-tab" style="display: none;">
                <ul class="layui-tab-title attribute-name">
                </ul>
                <div class="layui-tab-content attribute-value"></div>
              </div>
              <button class="layui-btn display" type="button">生成属性</button>
 -->
              <div class="tab-content end-table">
                <table class="layui-table">
                  <thead class="thead">
                    <thead class="thead">
                      <tr style="background-image: -webkit-linear-gradient(top, #ffffff 0%, #f2f2f2 100%)">
                        <?php foreach ($attrlist['thead'] as $val):?>
                        <th class="width100"><?= $val?></th>
                        <?php endforeach;?>
                        <th class="width100">原价</th>
                        <th class="width100">折扣价</th>
                        <th class="width100">库存</th>
                        <th class="width100">图片</th>
                      </tr>
                    </thead>
                  </thead>
                  <tbody class="tbody">
                    <?php foreach ($attrlist['tbody'] as $key=>$val):?>
                      <tr>
                        <?php foreach ($val['val'] as $value):?>
                          <td><?= $value?></td>
                        <?php endforeach;?>
                        <td><input class="no_b need layui-input" type="text" name="original_price" placeholder="0.00" value="<?= $val['original_price']?>"></td>
                        <td><input class="no_b need layui-input" type="text" name="discount_price" placeholder="0.00" value="<?= $val['discount_price']?>"></td>
                        <td><input class="no_b need layui-input" type="text" placeholder="0" name="inventory[]" value="<?= $val['inventory']?>"></td>
                        <td class="td_img">
                        <label>修改<input style="display: none" class="no_b1 pic-card pic-card4" type="file" indexs="<?= $key+1?>">
                        <img class="img_pic<?=$key+1?>" src="<?= $val['image']?>"><input type="hidden" name="attrimgval" value="<?= $val['images'] ?>" class="attrimgvalue need  attrList imgindex<?= $key+1?>"></label></td>
                        <td style="display: none;"><input value="<?= $val['attribute_value_id']?>" class="need"></td>
                        <input type="hidden" value="<?= $val['id']?>" class="need">
                      </tr>
                    <?php endforeach;?>
                  </tbody>
                </table>
              </div>
            </div>
          </div>
        </li>
        <li>
          <span class="title">属性描述</span>
          <div class="item">
            <dl>
              <dt>
                <span class="layui-btn add_attr_describe">添加属性描述</span>
              </dt>
              <dd class="attr_describe">
                  <?php foreach ($attr_des as $val):?>
                <div data-id="<?= $val['id']?>">
                  <span>
                    <input type="text" name="key" class="layui-input" placeholder="属性" value="<?= $val['key']?>" />
                    <input type="text" name="val" class="layui-input" placeholder="描述" value="<?= $val['val']?>" />
                  </span>
                  <b class="layui-btn del_attr_describe">删除</b>
                </div>
                  <?php endforeach;?>
              </dd>
            </dl>
          </div>
        </li>
        <li class="yf">
          <span class="title">运费</span>
          <div class="item"><span>统一运费 <input type="text" class="layui-input layui-input-inline" name="freight" value="<?php echo $goods['freight']; ?>" /></span></div>
        </li>
        <li>
          <span class="title">商品描述</span>
          <div class="item">
            <textarea name="desc" placeholder="请输入内容" class="layui-textarea" id="introduction"><?php echo $goods['introduction'] ?></textarea>
            <p style="text-align: right;"><span class="introduction_count">0</span>/220</p>
          </div>
        </li>
        <li>
          <span class="title">详情图</span>
          <div class="item">
            <div class="show-pic" style="width: 100px;">
              <span class="btn btn-file" style="display: none;">
                  <span class="fileupload-new">请选择图片</span>
                        <input type="file" class="default" id="choosepic">
                        <input type="hidden" name="list_img" value="" class="hidden-pic">
                      </span>
                <label for="choosepic"><span class="layui-btn"><i class="layui-icon">&#xe67c;</i>上传图片详情图</span></label>
                <input type="hidden" name="list_img" value="" class="hidden-pic">
            </div>
            <div class="imgs" style="margin-top: 20px;">
              <?php if(!empty($goods['banner'])):?>
                <?php foreach ($goods['banner'] as $ban):?>
                  <div style="display:inline-block;">
                    <div class="detail-img" style="width:150px;height:150px;position:relative; margin-right:10px;">
                      <img src="<?= GlobalUrlService::buildCdnUrl($ban['img_url'])?>" style="width:100%;height:100%;">
                      <input type="hidden" name="img_url" class="hidden-picc" value="<?= $ban['img_url']?>">
                      <div class="xxx" style="position:absolute;top:0;right:0;width:20px;height:20px;line-height:20px;text-align:center;background:#ddd;cursor:pointer;">X</div>
                    </div>
                  </div>
                <?php endforeach ;?>
              <?php endif?>
            </div>
          </div>
        </li>
      </ul>
    </form>
    <div class="btns">
      <input type="hidden" name="goods_id"  value="<?= $goods['id']?>">
      <button class="layui-btn btn-last-googs" id="qued">确定</button>
      <a class="layui-btn layui-btn-primary" onclick="window.history.go(-1);">取消</a>
    </div>
  </div>
</div>


